home *** CD-ROM | disk | FTP | other *** search
- Path: mail2news.demon.co.uk!genesis.demon.co.uk
- From: Lawrence Kirby <fred@genesis.demon.co.uk>
- Newsgroups: comp.lang.c
- Subject: Re: A question about STRING.
- Date: Mon, 29 Jan 96 22:56:41 GMT
- Organization: none
- Message-ID: <822956201snz@genesis.demon.co.uk>
- References: <4e0akh$853@erinews.ericsson.se> <4ej6tc$svf@news.acns.nwu.edu>
- Reply-To: fred@genesis.demon.co.uk
- X-NNTP-Posting-Host: genesis.demon.co.uk
- X-Newsreader: Demon Internet Simple News v1.27
- X-Mail2News-Path: genesis.demon.co.uk
-
- In article <4ej6tc$svf@news.acns.nwu.edu>
- muzaffar@casbah.acns.nwu.edu "Usman Muzaffar" writes:
-
- >>In my program, there is a variable MUTLI_RECORDS defined as char, which has a
- >>typical string as following:
- >>
- >>1,0,a,map010017000802532236,1,pp,0.2,1,0,map010017000802532236,acc,1,0. ...
- >>
- >>In fact, this string contains many records. Each record contains seven
- > columns.
- >>The columns in each record are seperated by the comma ','. Each record is
- >>terminated by a full stop '.'.
-
- >Doesn't the strtok function in the standard library do just this for you?
- >Split up an incoming string into tokens, and assign one to each.
- >Although, a simple while loop could do the trick, too.
-
- Maybe, maybe not - it depends on what exactly is wanted. strtok treats
- adjacent separator characters as a single separator (useful for dealing
- with, for example, whitespace) so 'tokens' must have a nonzero length.
- With a strict file format each separator character is typically significant
- and if that is the case (adjacent separators are possible) then strtok is
- not suitable.
-
- --
- -----------------------------------------
- Lawrence Kirby | fred@genesis.demon.co.uk
- Wilts, England | 70734.126@compuserve.com
- -----------------------------------------
-